package cn.dulian.spring5.service;

import cn.dulian.spring5.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * @author dulian
 * @create 2022-04-15 13:35
 */
//注解里面value属性值可以省略不写
    //默认值是类名称， 首字母小写
//@Component(value = "userService")
    @Service
public class UserService {
    //定义dao类型属性
    //不需要添加set方法
    //添加注入属性注解
    @Autowired//根据类型进行注入
    @Qualifier(value = "userDaoImp")//根据名称进行注入，而且要和autowired一起
    private UserDao userDao;
    public void add(){
        System.out.println("service add...");
        userDao.add();
    }
}
